package rsb21411ls.d1124HomeWork;



import java.util.*;

public class StudentTest {
    static List<Students> list=new ArrayList<>();
    public static void main(String[] args) {
        init();
        System.out.println("全班的Java平均分是"+Students.getAvg(list));//求平均成绩
        Students stu1=new Students("41926081","唐凯悦","f",80,80.7);
        Students stu2=new Students("4192661","姚之涵","f",66,71.6);
        Students stu3=new Students("48646","安典","m",55,64.3);
        Students stu4=new Students("41926081","张小艳","f",5,90);
        Students stu5=new Students("4192521","成龙","f",53,99);
        TreeSet Students =new TreeSet<>(new Comparator<Students>(){//用树排序
            @Override
            public int compare(Students o1, Students o2) {
                return Double.compare(o2.getsJava(),o1.getsJava());
            }
        });
        Students.add(stu1);Students.add(stu2);Students.add(stu3);Students.add(stu4);Students.add(stu5);
        System.out.println("Student列表:"+Students);
        System.out.println("最小值是"+Students.last());//最低分
        System.out.println("最大值是:"+Students.first());//最高分
    }

    public static void init(){
        Students stu1=new Students("41926081","唐凯悦","f",80,80.7);
        Students stu2=new Students("4192661","姚之涵","f",66,71.6);
        Students stu3=new Students("48646","安典","m",55,64.3);
        Students stu4=new Students("41926081","张小艳","f",5,90);
        Students stu5=new Students("4192521","成龙","f",53,99);
        Collections.addAll(list,stu1,stu2,stu3,stu4,stu5);
    }}

